package de.tabuma.wsdl2xform.xform.controller;

import de.tabuma.wsdl2xform.xform.view.view;
import de.tabuma.lib.tabumacontroller;
import de.tabuma.wsdl2xform.controller.*;
import de.tabuma.wsdl2xform.xform.constants;
import java.util.logging.*;
import java.io.*;
import java.util.Hashtable;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author $Author: alefen $
 * @version $Revision: 1.3 $
 * @since $Date: 2009/12/30 01:10:56 $
 */
public class controller extends tabumacontroller {

    private static Logger log =  Logger.getLogger(controller.class.getName());

    public controller(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {

        int nav = 0;
        if(request.getParameter(constants.XFORM_NAV)!=null) {
            nav = Integer.valueOf(request.getParameter(constants.XFORM_NAV)).intValue();
        }

        switch(nav) {
            case constants.NAV_NULL:
                log.fine("Giving focus to "+projectOverview.class.getName());
                projectOverview xformoverviewcontroller = new projectOverview(this.getServlet(), this.getParameter());
                xformoverviewcontroller.navigate(context, request, response, out);
                break;
            case constants.NAV_FIRST_STEP:
                log.fine("Giving focus to "+projectPage1.class.getName());
                projectPage1 projectpage1 = new projectPage1(this.getServlet(), this.getParameter());
                projectpage1.navigate(context, request, response, out);
                break;
            case constants.NAV_SECOND_STEP:
                log.fine("Giving focus to "+projectPage2.class.getName());
                projectPage2 projectpage2 = new projectPage2(this.getServlet(), this.getParameter());
                projectpage2.navigate(context, request, response, out);
                break;
            case constants.NAV_SHOW_PROJECT:
                log.fine("Giving focus to "+projectPage3.class.getName());
                projectPage3 projectpage3 = new projectPage3(this.getServlet(), this.getParameter());
                projectpage3.navigate(context, request, response, out);
                break;
        }

        view xform = new view(this.getServlet(), this.getParameter());
        xform.processRequest(context, request, response, out);
        
    }

}
